package com.mycompany.prog;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 * Hello world!
 *
 */
public class App {

    public static void main(String[] args) {
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("UNIT");
        EntityManager manager = factory.createEntityManager();
        manager.getTransaction().begin();
        Query query = manager.createQuery("from Car");
        List<Car> Cars = (List)query.getResultList();
        for (Object a: Cars) {
            System.out.println((Car)a);
        }
        manager.getTransaction().commit();
    }
}
